#include "tachyon/crypto/random/cha_cha20/cha_cha20_rng.h"

#include "gtest/gtest.h"

namespace tachyon::crypto {

TEST(ChaCha20RNGTest, NextUint64) {
  uint64_t expected[100] = {
      UINT64_C(10393729187455219830), UINT64_C(2935650227004792128),
      UINT64_C(1940362735889535677),  UINT64_C(14343251830567286440),
      UINT64_C(10180482965161198042), UINT64_C(3984235106219861111),
      UINT64_C(2062956586891494250),  UINT64_C(9684409023775279043),
      UINT64_C(8806878500039886751),  UINT64_C(939050496341555864),
      UINT64_C(7594726247694405579),  UINT64_C(17112251633709073938),
      UINT64_C(4850067408395810601),  UINT64_C(15364549599435125205),
      UINT64_C(5042635551453211953),  UINT64_C(8020199874967036332),
      UINT64_C(16243400166531402029), UINT64_C(8475888955442691758),
      UINT64_C(14295220695038062990), UINT64_C(6751916914945475504),
      UINT64_C(1107176458225657601),  UINT64_C(2214742857283673640),
      UINT64_C(13876944814363366003), UINT64_C(17458382352914969439),
      UINT64_C(7734567147541635091),  UINT64_C(774568827527241941),
      UINT64_C(8297748152085231813),  UINT64_C(11858361222889432003),
      UINT64_C(3318454703339852845),  UINT64_C(4588149941567271405),
      UINT64_C(6203934359032441887),  UINT64_C(9085562760231545576),
      UINT64_C(12521492590937810661), UINT64_C(12762635606041057787),
      UINT64_C(3096410682545938149),  UINT64_C(5157591943273650122),
      UINT64_C(14488165282383183438), UINT64_C(9577362568275248150),
      UINT64_C(4079332552118504582),  UINT64_C(5587461883856785389),
      UINT64_C(5063541989730226400),  UINT64_C(1524727576459009209),
      UINT64_C(12085977716165202206), UINT64_C(15787106821018276889),
      UINT64_C(1920590957300281692),  UINT64_C(5957300950003652231),
      UINT64_C(2416862117611592572),  UINT64_C(5479067130089892010),
      UINT64_C(912532022007996146),   UINT64_C(7171791822103543488),
      UINT64_C(5461290933381004665),  UINT64_C(5182606474117124289),
      UINT64_C(1179899407735948526),  UINT64_C(6860028705977903330),
      UINT64_C(13960227638405752870), UINT64_C(3347080940407452016),
      UINT64_C(13839352340982246125), UINT64_C(731528835182815829),
      UINT64_C(16501257607314924491), UINT64_C(547481869190374323),
      UINT64_C(10971329490697310343), UINT64_C(6916228695646037994),
      UINT64_C(16280261910639226348), UINT64_C(15817793174876584019),
      UINT64_C(9074420358402181148),  UINT64_C(357118251176964789),
      UINT64_C(15272588994549399728), UINT64_C(13325403081000393433),
      UINT64_C(877970774918498640),   UINT64_C(15732295103341332567),
      UINT64_C(1940976211848945660),  UINT64_C(13386000513454104877),
      UINT64_C(7711777664747450393),  UINT64_C(8874701560112629883),
      UINT64_C(11994694005001377979), UINT64_C(14890135524144922226),
      UINT64_C(4179774647536864771),  UINT64_C(1478747169106552816),
      UINT64_C(7185786830989669347),  UINT64_C(13822778071138932147),
      UINT64_C(467554094344374893),   UINT64_C(8477030970323946282),
      UINT64_C(6235833977768581969),  UINT64_C(9405569865753553512),
      UINT64_C(13456404989354226680), UINT64_C(9288529277979812446),
      UINT64_C(13830455138970923676), UINT64_C(13836816604810330492),
      UINT64_C(17971588049683313305), UINT64_C(13554147842590742486),
      UINT64_C(15173774080656305358), UINT64_C(3196108095160856000),
      UINT64_C(840335128193248279),   UINT64_C(6100810389749577965),
      UINT64_C(14151766940868082726), UINT64_C(3296151717789255466),
      UINT64_C(13897386303572935112), UINT64_C(9025696065642439663),
      UINT64_C(7533880160997907807),  UINT64_C(3525968612637664997),
  };

  ChaCha20RNG rng;
  for (size_t i = 0; i < 100; ++i) {
    EXPECT_EQ(rng.NextUint64(), expected[i]);
  }
}

}  // namespace tachyon::crypto
